<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    
    <h:head>
        <title>#{names.title}</title>
    </h:head>
    
    <h:body rendered="#{!auth.loggedIn}">
        <ui:include src="login.xhtml" />
    </h:body>
    
    <h:body rendered="#{auth.loggedIn}">
        <h:outputStylesheet library="css" name="style.css"  />
        <h:form>
            <h:panelGroup layout="block" class="wrapper">
               <p:panel id="admin_panel" header="#{names.title}" style="margin-bottom:10px;">       
                   <ui:include src="header.xhtml" /> 
                   <p:panel id="edit_room_panel" header="#{names.roomEditPanelName}" style="margin-bottom:10px;" styleClass="small">
                        <h:panelGrid columns="3">
                            <p:outputLabel for="building" value="#{names.roomAttributeBuilding}" />
                            <p:inputText id="building" value="#{rooms.current.building}" required="true" requiredMessage="#{names.roomAttributeBuildingMsg}"/>
                            <p:message for="building" />
                            <p:outputLabel for="roomName" value="#{names.roomAttributeRoom}" />
                            <p:inputText id="roomName" value="#{rooms.current.name}" required="true" requiredMessage="#{names.roomAttributeRoomMsg}"/>
                            <p:message for="roomName" />
                        </h:panelGrid>
                    </p:panel>

                   
                    <p:panel id="match_rooms_panel" header="#{names.pickListPanelName}">
                        <p:pickList id="pickList" value="#{personPickList.data}" var="person" itemLabel="#{person}" itemValue="#{person}"
                                    showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains" converter="personConverter"
                                    style="margin: 0 auto" >
                            <f:facet name="sourceCaption"><p:outputLabel value="#{names.pickListSource}"/></f:facet>  
                            <f:facet name="targetCaption"><p:outputLabel value="#{names.pickListTarget}"/></f:facet>
                            <p:column>#{person.firstName} #{person.lastName}</p:column> 
                            <p:column>#{person.identityCardNumber}</p:column> 
                        </p:pickList>
                    </p:panel>
                        
                    <p:panel id="buttons" style="margin-top:10px;">
                        <h:panelGrid columns="3" style="margin: 0 auto">
                            <p:commandButton id="submit" icon="ui-icon-disk" value="#{names.buttonSubmit}" ajax="false" action="#{rooms.edit}"/>
                            <p:button id="cancel" value="#{names.buttonAbort}" outcome="showRoom" />
                            <p:commandButton id="deleteButton" icon="ui-icon-minus" value="#{names.buttonDelete}" onclick="confirmation.show()" type="button" />
                            <p:confirmDialog id="confirmDialog" message="#{names.roomDeleteConfirmBody}"  
                                    header="#{names.roomDeleteConfirmHeader}" severity="alert" widgetVar="confirmation">  
                                <p:commandButton id="confirm" icon="ui-icon-check" value="#{names.buttonYes}" onclick="confirmation.hide()" action="#{rooms.gotoDelete}">
                                </p:commandButton>
                                <p:commandButton id="decline" icon="ui-icon-close" value="#{names.buttonNo}" onclick="confirmation.hide()" type="button" />   
                            </p:confirmDialog> 
                        </h:panelGrid>
                    </p:panel>
                </p:panel>
            </h:panelGroup>    
        </h:form>
    </h:body>
</html>
